home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13081 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: bignews.shef.ac.uk!usenet
  2. From: Saul Cozens <s.cozens@sheffield.ac.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: pointer questions
  5. Date: Sat, 23 Mar 1996 10:34:28 +0000
  6. Organization: University of Sheffield, UK
  7. Message-ID: <3153D3B4.41C67EA6@sheffield.ac.uk>
  8. References: <4ifatf$5a8u@uvaix3e1.comp.UVic.CA> <4ifuv3$bf6@masala.cc.uh.edu>
  9. NNTP-Posting-Host: spike.shef.ac.uk
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; SunOS 4.1.4 sun4m)
  14.  
  15. Sensarn wrote:
  16. > cgesy@uvaix.uvic.ca (Colin Gesy) wrote:
  17. > >Could someone tell me if there is a difference
  18. > >between the declaration "int *thing_ptr" and
  19. > >"int* thing_ptr" ?
  20. > Not that I know of...
  21.  
  22. The only difference that I can think of is one of style - 
  23. I always thought that using
  24.     int* thing_ptr;
  25.  
  26. is potentially dangerous when declaring multiple pointers -
  27.     int* thing_ptr, another_ptr;
  28.  
  29. This looks (at first glance) that thing_ptr and another_ptr are
  30. both integer pointers - this is NOT the case - another_ptr 
  31. has, of course, been declared as an integer.
  32.  
  33. Group the '*' with  the variable name rather than the type
  34. reduces this confusion -
  35.  
  36.     int *thing_ptr, *another_ptr;
  37.  
  38. Pedantic I know - but programming style IS important.
  39.  
  40. Saul
  41. ==============================================================
  42. email:      mailto:s.cozens@sheffield.ac.uk
  43. WWW:        http://www.shef.ac.uk/~eee/esg/staff/suc_prof.html
  44. tel. work:  +44 (0)114 282 5188
  45. tel. home:  +44 (0)114 268 0385
  46.